package com.lyhlmj.oop_client.Frames.WaitFrame;

import com.lyhlmj.oop_client.Frames.PlayFrame.Panels.*;
import com.lyhlmj.oop_client.Utils.CenterUtils;
import com.lyhlmj.oop_client.Utils.ExitUtil;
import com.lyhlmj.oop_client.Utils.GetScreenSize;

import javax.swing.*;
import java.awt.*;

public class WaitFrame extends JFrame {
    public WaitFrame(String title) {
        super(title);
        ExitUtil.exitAfterLogin(this);

//        设置主控件为背景panel
        RootPanel rootPanel = new RootPanel();
        rootPanel.setLayout(new BorderLayout());
        this.setContentPane(rootPanel);

        WaitFrameButtonPanels waitFrameButtonPanels = new WaitFrameButtonPanels(this);
        waitFrameButtonPanels.setButtonFunction();
        rootPanel.add(waitFrameButtonPanels, BorderLayout.SOUTH);
    }

    public static void initial() {
        JFrame frame = new WaitFrame("五子棋系统——游戏大厅");

        //  得到Frame的大小
        int width = GetScreenSize.getFitSize()[0];
        int height = GetScreenSize.getFitSize()[1];

        frame.setSize(width, height);//设置框架的高度和宽度
        frame.setVisible(true);//设置可见性

//        设置框架显示在屏幕正中间
        CenterUtils.centerInScreen(frame);
    }
}
